package cn.project.action;

import cn.project.model.Page;
import cn.project.model.User;
import cn.project.service.IUserService;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class UserAction extends ActionSupport implements ModelDriven<Object> {

    private IUserService userService;
    /**
     *
     * 用户对象参数
     *
     */
    private User user;
    /**
     *
     * 每页大小参数
     *
     */
    private int pageSize;
    /**
     *
     * 当前页码参数
     *
     */
    private int pageNum;
    /**
     *
     * 返回分页数据对象
     *
     */
    private Page page;


    /*模糊查询用户列表*/
    public  String queryLikeUsers(){

        Map<String,Object> cond=new HashMap<String,Object>();
        cond.put("pageSize",pageSize);
        cond.put("pageNum",pageNum);
        cond.put("user",user);
        page=userService.queryLikeUsers(cond);

        return SUCCESS;
    }

    public IUserService getUserService() {
        return userService;
    }

    public void setUserService(IUserService userService) {
        this.userService = userService;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public Page getPage() {
        return page;
    }

    public void setPage(Page page) {
        this.page = page;
    }

    @Override
    public Object getModel() {
        if (user == null) {
            user = new User();
        }
        return user;
    }
}
